package com.oh.database;

import java.util.Vector;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.oh.database.DatabaseHelper.Sreach_TB;

/**
 * 
 * 
 * @author Alex.Lu
 *
 */
public class CargoDao {
	
	
	/**
	 * 
	 * @param context
	 * @return
	 */
	public static Cursor querySearchItems(Context context,String searcherFilter){
		SQLiteDatabase db = DatabaseHelper.getInstance(context).getReadableDatabase();
		String[] columns = {
				Sreach_TB._ID,
				Sreach_TB.SREACH
		};
		Cursor c = db.query(Sreach_TB.TABLE_NAME, columns, Sreach_TB.SREACH + " like '%" + searcherFilter + "%'", null, null, null, null);
		return c;
	}

	/**
	 * 
	 * @param context
	 * @param search
	 */
	public static void insertSearch(Context context,Vector<String> searchs){
		SQLiteDatabase db = DatabaseHelper.getInstance(context).getWritableDatabase();
		db.beginTransaction();
		
		for(int i=0;i<searchs.size();i++){
			ContentValues values = new ContentValues();
			values.put(Sreach_TB.SREACH, searchs.get(i));
			db.insert(Sreach_TB.TABLE_NAME, null, values);
		}
		
		db.setTransactionSuccessful();
		db.endTransaction();
	}
	
	
	
	
}
